const { ccclass, property } = cc._decorator;
import n from "./frameworkManager";
import l from "./SdkHelper";
import s from "./BasePageCtrl";
import c from "./GameServiceMgr";
import u from "./UiManage";
import p from "./LoginOutPage";

@ccclass
export default class LoginOutPageCtrl extends s {
    @property(cc.Prefab)
    ui = null;

    onLoad() {
        super.onLoad();
        this.onUILoad();
        this._animType =AnimType.SCALE;
        this._touchControl = false;
        this._hasPeneLock = true;
        this._hasBlack = true;
        this._hasTouchLock = false;
        this.addButtonListen();
    }

    start() {
        this.ui.toggle_1.getComponent(cc.Toggle).isChecked = false;
        this.ui.toggle_2.getComponent(cc.Toggle).isChecked = false;
        this.ui.toggle_3.getComponent(cc.Toggle).isChecked = false;
    }

    onDisable() {
        this.ui.toggle_1.getComponent(cc.Toggle).isChecked = false;
        this.ui.toggle_2.getComponent(cc.Toggle).isChecked = false;
        this.ui.toggle_3.getComponent(cc.Toggle).isChecked = false;
    }

    onUILoad() {
        this.ui = this.node.addComponent(p);
    }

    addButtonListen() {
       UiManager.addButtonListen(this.ui.btn_jxsy, this.clickClose, this);
       UiManager.addButtonListen(this.ui.label_jxzx, this.touch_continueLogout, this, 2000);
    }

    touch_continueLogout() {
        n.log("touch_continueLogout");
        if (this.ui.toggle_1.getComponent(cc.Toggle).isChecked && this.ui.toggle_2.getComponent(cc.Toggle).isChecked && this.ui.toggle_3.getComponent(cc.Toggle).isChecked) {
            n.log("请求注销的接口");
            c.logoff();
        } else {
            l.showToast("您需同意所有条款，才能进行账号注销");
        }
    }

    clickClose() {
        this.hide();
    }
}
